//
//  UIView+dodoAnimation.m
//  TravelGuideMdd
//
//  Created by 陈曦 on 13-7-17.
//  Copyright (c) 2013年 mafengwo.com. All rights reserved.
//

#import "UIView+dodoAnimation.h"

@implementation UIView(dodoAnimation)

#define MAKE_ANIMAT(x,y) ([NSValue valueWithCATransform3D:CATransform3DMakeScale(x,y,1)])


- (void)dodoAnimation
{
    CAKeyframeAnimation *keyFrame = [CAKeyframeAnimation animationWithKeyPath:@"transform"];;
    
    keyFrame.values = @[
                        MAKE_ANIMAT(0.1, 0.1),
                        MAKE_ANIMAT(1.0, 1.0),
                        MAKE_ANIMAT(1.15, 0.85),
                        MAKE_ANIMAT(0.9, 1.1),
                        MAKE_ANIMAT(1.15, 0.97),
                        MAKE_ANIMAT(0.975, 1.025),
                        MAKE_ANIMAT(1, 1)
                        ];
    
//    NSArray *times = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0f],
//                      [NSNumber numberWithFloat:0.5f],
//                      [NSNumber numberWithFloat:0.9f],
//                      [NSNumber numberWithFloat:1.0f], nil];
//    [keyFrame setKeyTimes:times];
    
    keyFrame.duration = 0.4;
    keyFrame.fillMode = kCAFillModeForwards;
    keyFrame.removedOnCompletion = YES;
    
    [self.layer addAnimation:keyFrame forKey:@"dodoAnimation"];
}

@end
